home *** CD-ROM | disk | FTP | other *** search
/ Fritz: All Fritz / All Fritz.zip / All Fritz / FILES / PROGNG_C / MDSPL100.LZH / MDSPDEMO.C < prev    next >
C/C++ Source or Header  |  1987-11-16  |  6KB  |  153 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <stdarg.h>
  5. #include <dos.h>
  6. #include <conio.h>
  7. #include <ctype.h>
  8. #include "mdisplay.h"
  9.  /*   This is a demonstration program that illustrates the use of     */
  10.  /*   the various mwin utility routines.  These routines provide an   */
  11.  /*   interface to the secondary (mono) system monitor.  Routines are */
  12.  /*   available to initialize the secondary monitor, create and       */
  13.  /*   destroy windows, enable and disable the video signal, clear     */
  14.  /*   a window, scroll a window, and write to a window.  The output   */
  15.  /*   to a window is a TTY type output.  Additional routines are      */
  16.  /*   available to determine the output position to and change that   */
  17.  /*   position within a window.  One default (full screen) and up to  */
  18.  /*   8 program defined windows are available.                        */
  19.  
  20.    char         input;
  21.    int          attrb;
  22.    int          wind1,wind2,wind3,wind4;
  23.    struct mwctl mwin_status;
  24.  
  25. main(argc, argv)
  26.      int    argc;
  27.      char   *argv[];
  28. {
  29.    int   i,j;
  30.    if (initMono() == ERROR)
  31.       {  printf("Error in initializing mono card.  ");
  32.          printf("Program being terminated.\n");
  33.          exit();   }
  34.    printf("Filling the mono screen.\n");
  35.    input = 219;
  36.    attrb = 3;
  37.    for (i=0; i < 1999; i++)
  38.       { writeCharToMwin(0, input, attrb); }
  39.    printf("Creating first window.\n");
  40.    wind1 = createMwin(1,1,12,12);
  41.    if (wind1 == ERROR)
  42.       {  printf("Error in creating window 1.  ");
  43.          printf("Program being terminated.\n");
  44.          exit();   }
  45.    writeStringToMwin(wind1, "Window number 1", attrb);
  46.    printf("Creating second window.\n");
  47.    wind2 = createMwin(1,14,60,23);
  48.    if (wind2 == ERROR)
  49.       {  printf("Error in creating window 2.  ");
  50.          printf("Program being terminated.\n");
  51.          exit();   }
  52.    writeStringToMwin(wind2, "Window number 2\n", attrb);
  53.    printf("Creating third window.\n");
  54.    wind3 = createMwin(62,1,78,23);
  55.    if (wind3 == ERROR)
  56.       {  printf("Error in creating window 2.  ");
  57.          printf("Program being terminated.\n");
  58.          exit();   }
  59.    writeStringToMwin(wind3, "Window number 3", attrb);
  60.    wind4 = createMwin(14,1,60,12);
  61.    if (wind4 == ERROR)
  62.       {  printf("Error in creating window 4.  ");
  63.          printf("Program being terminated.\n");
  64.          exit();   }
  65.    writeStringToMwin(wind4, "Window number 4", attrb);
  66.    printf("Press any key to continue.\n");
  67.    input = getch();
  68.    disableMwin();
  69.    printf("Mono video disabled.\n");
  70.    printf("Press any key to continue.\n");
  71.    input = getch();
  72.    enableMwin();
  73.    printf("Mono video enabled.\n");
  74.    printf("Press any key to continue.\n");
  75.    input = getch();
  76.    attrb = 3;
  77.    printf("Enter text for Window 1.  Press ESC to quit.\n");
  78.    input = getch();
  79.    for ( ;!eof(fileno(stdin)) & input!=27; ) /* quit on eof or ESC*/
  80.        { writeCharToMwin(wind1, input, attrb);
  81.        input = getch();
  82.        }
  83.    attrb = 9;
  84.    printf("Enter text for Window 2.  Press ESC to quit.\n");
  85.    input = getch();
  86.    for ( ;!eof(fileno(stdin)) & input!=27; ) /* quit on eof or ESC*/
  87.        { writeCharToMwin(wind2, input, attrb);
  88.        input = getch();
  89.        }
  90.    attrb = 24;
  91.    printf("Enter text for Window 3.  Press ESC to quit.\n");
  92.    input = getch();
  93.    for ( ;!eof(fileno(stdin)) & input!=27; ) /* quit on eof or ESC*/
  94.        { writeCharToMwin(wind3, input, attrb);
  95.        input = getch();
  96.        }
  97.    attrb = 240;
  98.    printf("Enter text for Window 4.  Press ESC to quit.\n");
  99.    input = getch();
  100.    for ( ;!eof(fileno(stdin)) & input!=27; ) /* quit on eof or ESC*/
  101.        { writeCharToMwin(wind4, input, attrb);
  102.        input = getch();
  103.        }
  104.    printf("Destroying second window.\n");
  105.    if (destroyMwin(wind2) == ERROR)
  106.       {  printf("Error in destroying window 2.  ");
  107.          printf("Program being terminated.\n");
  108.          exit();   }
  109.    printf("Destroying third window.\n");
  110.    if (destroyMwin(wind3) == ERROR)
  111.       {  printf("Error in destroying window 3.  ");
  112.          printf("Program being terminated.\n");
  113.          exit();   }
  114.    printf("Destroying forth window.\n");
  115.    if (destroyMwin(wind4) == ERROR)
  116.       {  printf("Error in destroying window 4.  ");
  117.          printf("Program being terminated.\n");
  118.          exit();   }
  119.    printf("Recreating second window.\n");
  120.    wind2 = createMwin(1,14,78,23);
  121.    if (wind2 == ERROR)
  122.       {  printf("Error in creating window 2.  ");
  123.          printf("Program being terminated.\n");
  124.          exit();   }
  125.    printf("Recreating third window.\n");
  126.    wind3 = createMwin(14,1,78,12);
  127.    if (wind3 == ERROR)
  128.       {  printf("Error in creating window 3.  ");
  129.          printf("Program being terminated.\n");
  130.          exit();   }
  131.    input = 219;
  132.    attrb = 3;
  133.    setMwin(0,62,13);            /* Refill the background */
  134.    for (i=0; i < 17; i++)
  135.       { writeCharToMwin(0, input, attrb); }
  136.    attrb = 3;
  137.    writeStringToMwin(wind2, "Window number 2\n", attrb);
  138.    for (i=0; i < 6; i++)
  139.       { writeStringToMwin(wind2, "Test output to window.\n", attrb);}
  140.    if (getMwinStatus(wind2, &mwin_status) == ERROR)
  141.       {  printf("Error in window status.  ");
  142.          printf("Program being terminated.\n");
  143.          exit();   }
  144.    printf("Status for window %i\n", wind2);
  145.    printf("Status for window %i\n", mwin_status.mwin);
  146.    printf("  Current line:   %i\n", mwin_status.line);
  147.    printf("  Current column: %i\n", mwin_status.column);
  148.    writeStringToMwin(wind3, "Window number 3\n", attrb);
  149.    printf("Press any key to end program.\n");
  150.    input = getch();
  151.    initMono();
  152. }
  153.